extends "../../../azurlane_ctrl/Boss.gd"

var baseId = ""
func _extInit():
	._extInit()
	chaName = "「高级塞壬」侵扰者Ⅲ型"   #角色的名称
	attInfox.maxHp = 44444
	attInfox.atk = 400
	attInfox.mgiAtk = 400
	attInfox.def = 180
	attInfox.dod = 50
	attInfox.cd += 0.3
	attInfox.spd += 0.3
	attInfox.atkRan = 8
	lv = 4            #等级的设置
	ename = "qingraozhe"
	addSkill("开局闪现至同行最后一格，对最近的敌人及其周围1格(九宫格)造成总计[炮击*20]的技能伤害(所有受击目标均摊伤害)", "侵袭")
	addSkill("造成击杀时，立即对该目标周围2格的敌人造成[炮击*4]的技能伤害", "燃灰")
	addSkill("每{cd}秒对距离最远的[非召唤]敌人造成[炮击*6]的炮击伤害", "狙击", "qinraozhe3", 6)

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "qinraozhe3":
		qinraozhe3()

func qinraozhe3():
	var cha = getFirstCha(1, "sortByDistance", false, false, true)
	if cha != null:
		var eff2 = createCustEff(position, "eff/bodaodan", 0, false, 1, Vector2(-30, -30))
		eff2._initFlyCha(cha, 500)
		yieldOnReach(eff2)
		azurHurtChara(cha, att.atk*6, sys.HurtType.WEAPON, sys.AtkType.GUN, "狙击")

func _onBattleStart():
	._onBattleStart()
	qinraozhe1()

func qinraozhe1():
	yield(reTimer(0.05), "timeout")
	var mv = Vector2(cell.x ,cell.y)
	mv.x = 0
	for i in config.aroundCellEx:
		var v = mv + i
		if matCha(v) == null and sys.main.isMatin(v):
			if setCell(v):
				var pos = sys.main.map.map_to_world(cell)
				ying(pos)
				position = pos
				aiCha = null
				break
	yield(reTimer(0.1), "timeout")

	var cha = getFirstCha(1, "sortByDistance", false, false, true)
	var chas = getNearChas(cha.cell, false, cha)
	var dmg = att.atk*20.0/chas.size()
	createCustEff(aiCha.position, "eff/wanjianguizong", 15, false, 3, Vector2(0, 0))
	yield(reTimer(0.2),"timeout")
	for i in chas:
		azurHurtChara(i, dmg, sys.HurtType.WEAPON, sys.AtkType.SKILL, "侵袭")

func _onKillChara(atkInfo):
	._onKillChara(atkInfo)
	for i in getCellChas(atkInfo.hitCha.cell, 2, 1):
		if i != atkInfo.hitCha:
			azurHurtChara(i, att.atk*4, sys.HurtType.WEAPON, sys.AtkType.SKILL, "燃灰")

func getItems():
	addItem(sys.newItem(itemData.rndGetEquipEx(itemData.EquipType.DEF)))		
	addItem(sys.newItem(itemData.rndGetEquipEx(itemData.EquipType.DEF)))	
	addItem(sys.newItem(itemData.rndGetEquipEx(itemData.EquipType.AD)))

	for it in items:
		if it.has_method("upgrade"):
			it.upgrade()
			it.upgraded = true